package com.lantosec.hmrp.modules.form.controller;

import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.form.service.IFormService;
import com.lantosec.hmrp.modules.form.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * 自定义表单 控制器
 *
 * @author AutoCode
 * @since 2020-04-22
 */
@Api(value = "自定义表单控制器", tags = "自定义表单控制器")
@RestController
@RequestMapping("/form/")
@Log4j2
public class FormController extends BaseController {

    @Autowired
    IFormService formService;

    /*@Deprecated
    @PostMapping("save")
    @ApiOperation(value = "保存表单数据")
    public Result<String> save(@ApiParam(value = "表单数据", required = true) @RequestBody String formData) {
        return formService.save(new SaveProcessTaskVO("935732a41c62b4c2404d37ac363589ec", formData));
    }

    @GetMapping("get")
    @ApiOperation(value = "根据表单Id和流程Id获取表单数据")
    public Result<FormVO> get(@ApiParam(value = "查询对象", required = true) QueryFormVO condition) {
        return formService.queryDataByFormId(condition.getLayoutId(), condition.getTaskId());
    }*/

    @PostMapping("calculateValue")
    @ApiOperation(value = "计算值字段的值")
    public Result<Object> calculateValue(@ApiParam(value = "计算字段值VO对象", required = true) @RequestBody CalculateValueVO calculateValueVO) {
        return formService.calculateValue(calculateValueVO);
    }

    @PostMapping("decisionSupport")
    @ApiOperation(value = "辅助决策")
    public Result<DecisionSupportResultVO> decisionSupport(@ApiParam(value = "辅助决策VO对象", required = true) @RequestBody DecisionSupportVO entity) {
        return formService.decisionSupport(entity);
    }
}
